\documentclass[10pt,oneside]{book}

\input{macros_orig.tex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\pagestyle{empty}
\thispagestyle{empty}

\begin{codebox}
  \Procname{$\proc{Infinite-Horizon-Value-Iteration}(\mathcal S, \mathcal A, T, R, \gamma, \epsilon)$}
  \li     \For $s \in \mathcal{S}, a \in \mathcal{A}:$
	\Do
  \li        $Q_{\text{old}}(s, a) = 0$
        \End
  \li     \While True:
        \Do
  \li        \For $s \in \mathcal{S}, a \in \mathcal{A}:$
           \Do
  \li           $Q_{\text{new}}(s, a) = R(s, a) + \gamma\sum_{s'}T(s, a, s')\max_{a'}Q_{\text{old}}(s', a')$
         \End

  \li      \If $\max_{s, a}\lvert Q_{\text{old}}(s, a) - Q_{\text{new}}(s, a)\rvert < \epsilon:$
         \Do
  \li           return $Q_{\text{new}}$
        \End
  \li      $Q_{\text{old}} = Q_{\text{new}}$
	\End
\end{codebox}

\end{document}
